import { RouteRecordRaw } from 'vue-router';

export const pageConfigRouter: Array<RouteRecordRaw> = [
  {
    path: 'page-config',
    name: 'PageConfig',
    component: () =>
      import(/* webpackChunkName: "PageConfig" */ '@/views/page-config/PageConfig.vue'),
    children: [
      {
        path: 'form',
        name: 'FormConfig',
        component: () =>
          import(/* webpackChunkName: "PageConfig" */ '@/views/page-config/form/FormConfig.vue')
      },
      {
        path: 'create-form',
        name: 'CreateFormConfig',
        component: () =>
          import(
            /* webpackChunkName: "PageConfig" */ '@/views/page-config/form/CreateFormConfig.vue'
          ),
        meta: { name: '创建表单', menuId: 'form' },
        // props: true // TODO 在vue-router4.1.4之后，使用name跳转路由，传递params参数的功能失效了
        props: route => {
          const params: any = {};
          Object.keys(route.query).forEach(key => {
            params[key] = route.query[key];
          });
          return params;
        }
      },
      {
        path: 'table',
        name: 'TableConfig',
        component: () =>
          import(/* webpackChunkName: "PageConfig" */ '@/views/page-config/table/TableConfig.vue')
      },
      {
        path: 'create-table',
        name: 'CreateTableConfig',
        component: () =>
          import(
            /* webpackChunkName: "PageConfig" */ '@/views/page-config/table/CreateTableConfig.vue'
          ),
        meta: { name: '创建表格', menuId: 'table' },
        // props: true // TODO 在vue-router4.1.4之后，使用name跳转路由，传递params参数的功能失效了
        props: route => {
          const params: any = {};
          Object.keys(route.query).forEach(key => {
            params[key] = route.query[key];
          });
          return params;
        }
      },
      {
        path: 'layout',
        name: 'LayoutConfig',
        component: () =>
          import(/* webpackChunkName: "PageConfig" */ '@/views/page-config/layout/LayoutConfig.vue')
      },
      {
        path: 'meta-data',
        name: 'MetadataConfig',
        component: () =>
          import(
            /* webpackChunkName: "PageConfig" */ '@/views/page-config/meta-data/MetadataConfig.vue'
          )
      },
      {
        path: 'flow',
        name: 'FlowDesign',
        component: () =>
          import(/* webpackChunkName: "PageConfig" */ '@/views/page-config/flow/FlowList.vue')
      },
      {
        path: 'flow-todos',
        name: 'FlowTodoList',
        component: () =>
          import(
            /* webpackChunkName: "PageConfig" */ '@/views/page-config/flow/todos/FlowTodoList.vue'
          )
      },
      {
        path: 'flow-dones',
        name: 'FlowDoneList',
        component: () =>
          import(
            /* webpackChunkName: "PageConfig" */ '@/views/page-config/flow/dones/FlowDoneList.vue'
          )
      }
    ]
  }
];
